<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改教师信息')"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-teacher-edit" th:object="${eduTeacher}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">姓名：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">性别：</label>
            <div class="col-sm-8">
                <div class="radio-box" style="height: 34px;" th:each="dict : ${@dict.getType('edu_sex')}">
                    <input type="radio" th:id="${'sex_' + dict.id}" name="sex" th:value="${dict.itemValue}"
                           th:field="*{sex}">
                    <label th:for="${'sex_' + dict.id}" th:text="${dict.itemText}"></label>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">民族：</label>
            <div class="col-sm-8">
                <input name="national" th:field="*{national}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">出生日期：</label>
            <div class="col-sm-8">
                <input name="birthday" th:field="*{birthday}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">职务：</label>
            <div class="col-sm-8">
                <select name="position" class="form-control m-b" th:with="type=${@dict.getType('edu_position')}">
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"
                            th:field="*{position}"></option>
                </select>
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">学历：</label>
            <div class="col-sm-8">
                <select name="educationBackground" class="form-control m-b"
                        th:with="type=${@dict.getType('edu_background')}">
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"
                            th:field="*{educationBackground}"></option>
                </select>
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">参加工作：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="workTime" th:value="${#dates.format(eduTeacher.workTime, 'yyyy-MM-dd')}"
                           class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">身份证号：</label>
            <div class="col-sm-8">
                <input name="idNumber" th:field="*{idNumber}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">户口所在地：</label>
            <div class="col-sm-8">
                <input name="residenceLocation" th:field="*{residenceLocation}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">手机号码：</label>
            <div class="col-sm-8">
                <input name="mobilePhone" th:field="*{mobilePhone}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">办公座机：</label>
            <div class="col-sm-8">
                <input name="officePhone" th:field="*{officePhone}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">所在学校：</label>
            <div class="col-sm-8">
                <input name="school" th:field="*{school}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">任教学科：</label>
            <div class="col-sm-8">
                <input name="teachSubjects" th:field="*{teachSubjects}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">任教年级：</label>
            <div class="col-sm-8">
                <input name="teacheGrade" th:field="*{teacheGrade}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">任教班级：</label>
            <div class="col-sm-8">
                <input name="teacheClass" th:field="*{teacheClass}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">政治面貌：</label>
            <div class="col-sm-8">
                <input name="politicsStatus" th:field="*{politicsStatus}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group col-sm-12">
            <label class="col-sm-2 control-label" style="width: 16%;">家庭住址：</label>
            <div class="col-sm-9" style="width: 80%;">
                <input name="familyLocation" th:field="*{familyLocation}" class="form-control" type="text">
            </div>
        </div>
        <input name="photo" th:field="*{photo}" type="hidden">
        <div class="form-group" style="position:absolute; top:20px; right:25px;">
            <div class="fileinput fileinput-new" data-provides="fileinput"
                 style="position: relative; width:140px; height:160px;">
                <div class="fileinput-new thumbnail" style="width: 130px; height: 130px;">
                    <img th:src="(${eduTeacher.photo} == null) ? @{/res/img/touxiang.png} : @{'/sys/common/view/' + ${eduTeacher.photo}}">
                </div>
                <div class="fileinput-preview fileinput-exists thumbnail"
                     style="max-width: 200px; max-height: 130px;"></div>
                <div style="text-align: center;">
                        <span class="btn btn-white btn-file">
                            <span class="fileinput-new">选择图片</span>
                            <span class="fileinput-exists">更改</span>
                            <input type="file" id="williamYe">
                        </span>
                    <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12" style="text-align:center">
            <label class=" control-label">教师荣誉 获奖信息</label>
            <table style="width:auto;height:50px;margin-left: 30px;margin-right: 40px"
                   border="1" cellspacing="0" bordercolor="#686967">
                <tr style="text-align: center">
                    <th style="text-align: center">序号</th>
                    <th style="text-align: center">荣誉/获奖级别</th>
                    <th style="text-align: center">时间</th>
                    <th style="text-align: center">授予单位</th>
                    <th style="text-align: center">证书图片</th>
                </tr>
                <tr style="text-align: center">
                    <td>
                        <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                    </td>
                    <td>
                        <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                    </td>
                    <td>
                        <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                    </td>
                    <td>
                        <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                    </td>
                    <td>
                        <input class="form-control" type="text" style="text-align: center" placeholder="暂无数据">
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: jasny-bootstrap-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "education/teacher";
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#form-teacher-edit").validate({
        rules: {
            idNumber: {
                required: true,
                isIdentity: true
            }
        },
        messages: {
            idNumber: {
                required: icon + "请输入您的身份证号",
                isIdentity: icon + "请输入正确的身份证号"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-teacher-edit').serialize());
        }
    }

    $("input[name='workTime'],input[name='birthday']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
    $('#williamYe').on('change.bs.fileinput ', function (e) {
        // 处理自己的业务
        if (this.files[0]) {
            const formData = new FormData();
            formData.append('file', this.files[0]);
            $.operate.fileUpload(formData, $('input[name="photo"]'));
        } else {
            $('input[name="photo"]').val("");
        }
    });
</script>
</body>
</html>
